package cn.tedu.blackhorse.controller;

import cn.tedu.blackhorse.pojo.dto.CourseAddNewDTO;
import cn.tedu.blackhorse.pojo.dto.KnewProblemAddNewDTO;
import cn.tedu.blackhorse.pojo.vo.CourseListItemVO;
import cn.tedu.blackhorse.pojo.vo.KnewProblemListItemVO;
import cn.tedu.blackhorse.service.IKnewProblemService;
import cn.tedu.blackhorse.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/knew/problem")
@Api(tags = "回答学生问题")
@Validated
public class KnewProblemController {
    @Autowired
    IKnewProblemService knewProblemService;

    public KnewProblemController() {
        log.info("创建控制器：KnewProblemController");
    }
    @ApiOperation("增加回答学生问题")
    @ApiOperationSupport(order = 100)
    @ApiImplicitParam(name = "id", value = "课程id", required = true, dataType = "long")
    @PostMapping("/addNew")
    public JsonResult<Void> addNew(KnewProblemAddNewDTO knewProblemAddNewDTO) {
        log.debug("开始处理【增加回答学生问题】的请求");
        knewProblemService.insert(knewProblemAddNewDTO);
        return JsonResult.ok();
    }
    @ApiOperation("回答学生问题列表")
    @ApiOperationSupport(order = 200)
    @GetMapping("")
    public JsonResult<List<KnewProblemListItemVO>> list() {
        log.debug("开始处理【回答学生问题列表】的请求");
        List<KnewProblemListItemVO> list = knewProblemService.list();
        return JsonResult.ok(list);
    }
}
